package com.chinasofti.Collection;

import com.chinasofti.optional.Student;

import java.util.ArrayList;
import java.util.Collection;
import java.util.Iterator;

public class Demo06 {
    public static void main(String[] args) {
        Collection<Student> list=new ArrayList<>();
        Student s1=new Student("lilei",12);
        Student s2=new Student("hahajak",12);
        Student s3=new Student("dali",12);

        list.add(s1);
        list.add(s2);
        list.add(s3);

        for (Student st:list) {
            System.out.println("st = " + st);
        }
        Iterator it =list.iterator();
        while (it.hasNext()){
            Student stu=(Student) it.next();
            System.out.println("stu = " + stu);
        }

    }

}